package com.hue.springbootvalidation.domain;

import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @Author: yfq
 * @Date: 2022/8/4 15:47
 * @Description: 分组效验
 */
@Data
@ToString
public class Order {
    //@NotNull注解在UpdateOrder组下起作用
    @NotBlank(groups = {UpdateOrder.class}, message = "id不能为空")
    private String id;

    //@Length在SaveOrder和UpdateOrder两个组下起作用
    @NotBlank
    @Length(min = 8, max = 20, groups = {SaveOrder.class, UpdateOrder.class}, message = "userId长度在8-20位")
    private String userId;

    @NotNull
    @Length(min = 8, max = 20, groups = {SaveOrder.class, UpdateOrder.class}, message = "productId长度在8-20位")
    private String productId;

    public interface SaveOrder {

    }

    public interface UpdateOrder {

    }
}
